<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%--项目绝对路径--%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%--获取当前时间--%>
<jsp:useBean id="now" class="java.util.Date" scope="page"/>
<fmt:formatDate var="nowTime" value="${now}" pattern="yyyy-MM-dd HH:mm:ss"/>
<html>
<%


    String url = "jdbc:mysql://localhost:3306/carxianyu";
    String user = "root";
    String pwd = "root";


    Integer id =Integer.valueOf(request.getParameter("id"));
    String sql = "select * from car where id ="+id;
    System.out.println("执行了sql =====》"+sql);
    //jdbc 连接数据库
    Class.forName("com.mysql.jdbc.Driver");//加载驱动
    Connection conn = DriverManager.getConnection("jdbc:mysql://43.142.239.28:13307/carxianyu?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC","root","root");
    PreparedStatement a = conn.prepareStatement(sql);
    ResultSet rs = a.executeQuery();



%>

<head>
    <title>用户修改页面</title>
    <!-- 引入css样式和js文件-->
    <meta charset="UTF-8">
    <base href="${ctx}/"/>
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${ctx}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${ctx}/static/js/common.js"></script>
    <script>
        var ctx = '${ctx}/';
    </script>
</head>
<body>
<div class="layui-container">

    <% while(rs.next()){

        //为列表参数初始化

        String number  = rs.getString("number");
        id = rs.getInt("id");
        String name = rs.getString("name");
        String images = rs.getString("images");
        String price = rs.getString("price");
        String introduction = rs.getString("introduction");
        String address = rs.getString("address");
        Integer age =Integer.valueOf( rs.getString("age"));
        String createtime = rs.getString("createtime");
        String identity = rs.getString("identity");


        String phone = rs.getString("phone");
        Integer collection =Integer.valueOf( rs.getString("collection"));
        Integer gearboxId =Integer.valueOf( rs.getString("gearbox"));

        String gearbox = null;
        if(gearboxId == 11){
            gearbox = "手动档";
        }else {
            gearbox= "自动档";
        }


    %>
    <img src="<%=images%> " style="width: 60%;border: 1px solid #cecece;padding: 20px;">
    <form class="layui-form  layui-form-pane" action="${ctx}/view/back/car/doCarExcute.jsp?" method="post" style="margin: 50px auto;">

        <div class="layui-form-item" hidden >
            <label class="layui-form-label">车id</label>
            <div class="layui-input-block">
                <input type="text" name="id" id="id" value="<%=id%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">车名</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name" value="<%=name%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>



        <div class="layui-form-item">
            <label class="layui-form-label">车牌</label>
            <div class="layui-input-block">
                <input type="text" name="number" id="number" value="<%=number%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">车图片网络地址</label>
            <div class="layui-input-block">
                <input type="text" name="images" id="images" value="<%=images%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车价</label>
            <div class="layui-input-block">
                <input type="text" name="price" id="price" value="<%=price%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车介绍</label>
            <div class="layui-input-block">
                <input type="text" name="introduction" id="introduction" value="<%=introduction%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">车地址</label>
            <div class="layui-input-block">
                <input type="text" name="address" id="address" value="<%=address%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车引擎</label>
            <div class="layui-input-block">


                    <input type="text" name="identity" id="gea" value="<%=gearbox%>" lay-verify autocomplete="off"
                           placeholder=""
                           class="layui-input">


            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车品牌</label>
            <div class="layui-input-block">
                <input type="text" name="identity" id="identity" value="<%=identity%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">车龄</label>
            <div class="layui-input-block">
                <input type="text" name="age" id="age" value="<%=age%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">电话号码</label>
            <div class="layui-input-block">
                <input type="text" name="phone" id="" value="<%=phone%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item" hidden>
            <label class="layui-form-label">收藏人数</label>
            <div class="layui-input-block">
                <input type="text" name="collection" id="collection" value="<%=collection%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>

        </div>

        <div class="layui-form-item" hidden>
            <label class="layui-form-label">收藏人数</label>
            <div class="layui-input-block">
                <input type="text" name="createtime" id="createtime" value="<%=createtime%>" lay-verify autocomplete="off"
                       placeholder=""
                       class="layui-input">
            </div>

        </div>







        <c:if test="${sessionScope.depart == 11}">
        <div class="layui-form-item" >
            <label class="layui-form-label">是否通过审核</label>
            <div class="layui-input-block">
                <select name="status" id="status" class="layui-select">
                    <option value="22" selected>审核通过</option>
                    <option value="33" selected>审核拒绝</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item" hidden>
            <label class="layui-form-label">审核</label>
            <div class="layui-input-block">
                <select name="state" id="state" class="layui-select">
                    <option value="7" selected>新增</option>

                </select>
            </div>
        </div>



        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">提交审核</button>
            </div>
        </div>
        </c:if>
    </form>

    <%}%>

</div>
<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    //定义layui的变量
    var $;
    var layer;
    var element;
    var form;
    layui.use(['element', 'layer', 'jquery', 'form', 'laydate', 'layedit'], function () {
        element = layui.element;
        layer = layui.layer;
        $ = layui.jquery;
        form = layui.form;
        var laydate = layui.laydate;
        var layedit = layui.layedit;

        //监听提交
        form.on('submit(demo1)', function (data) {
            console.log(JSON.stringify(data.field));
            return true;
        });

    });
</script>

</body>
</html>
